#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define mes(x) memset(x,0,sizeof(x))
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 2e5+10;

vector<int> G[MAXN],T[MAXN];
int cnt,n,m,val[MAXN],siz[MAXN],dfn[MAXN],low[MAXN],tot,stk[MAXN],top,SIZ;
ll ans;

void tarjan(int x){
	low[x] = dfn[x] = ++tot; stk[++top] = x; SIZ++;
	for(int y : G[x]){
		if(!dfn[y]) {
			tarjan(y),low[x] = min(low[x],low[y]); 
			if(low[y] >= dfn[x]){
				++cnt; T[cnt].push_back(x); T[x].push_back(cnt); val[x] = -1;val[cnt] = 1;
				do{
					val[cnt]++;val[stk[top]] = -1;
					T[cnt].push_back(stk[top]); T[stk[top]].push_back(cnt);
				}while(stk[top--] != y);
			}
		}else low[x] = min(low[x],dfn[y]);
	}
}

void dfs(int x,int p){
	siz[x] = x <= n;
	for(int y : T[x]){
		if(y == p) continue;
		dfs(y,x); ans += 2ll * siz[x] * siz[y] * val[x]; siz[x] += siz[y]; 
	}ans += 2ll * (SIZ - siz[x]) * siz[x] * val[x];
}

int main (){
	n = in,m = in;cnt = n;
	for(int i = 1;i <= m;i++){int x = in,y = in;G[x].push_back(y);G[y].push_back(x);}
	for(int i = 1;i <= n;i++) if(!dfn[i]) {SIZ = 0;top = 0;tarjan(i);dfs(i,0);}
	printf("%lld\n",ans);
	return 0;
}
